<?php

include_once dirname(dirname(__FILE__)) . '/include/common.php';
$core = new core();
$customer_order_id = isset($_POST["customer_order_id"]) ? intval($_POST["customer_order_id"]) : 0;
if ($customer_order_id == "" || $customer_order_id <= 0) {
    echo json_encode(array('type' => 1, 'msg' => "Có lỗi xảy ra, vui lòng thử lại!"));
    die;
} else {
    $customer_order = $core->getCustomerOrderDetailById($customer_order_id);
    if ($customer_order) {
        if ($customer_order->code_view == '') {
            $random_code = $core->generateRandomString(20);
            $core->db->query("UPDATE zen_customer_order SET code_view=$random_cod WHERE id= $customer_order_id");
        } else {
            $random_code = $customer_order->code_view;
        }
        echo json_encode(array('type' => 0, 'msg' => "Có lỗi xảy ra, vui lòng thử lại!"));
        die;

    }
}
?>
